package com.touzhijia.authority.service;

import com.touzhijia.authority.domain.entity.Permission;
import com.touzhijia.authority.domain.entity.WebPermission;
import com.touzhijia.authority.domain.model.WebPermissionDto;
import com.touzhijia.authority.mapper.PermissionMapper;
import com.touzhijia.authority.mapper.WebPermissionMapper;
import com.touzhijia.authority.utils.mapper.BeanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 作者： lzw<br/>
 * 创建时间：2018-03-20 21:10 <br/>
 */
@Transactional(readOnly = true)
@Service
public class WebPermissionService {

    @Autowired
    private PermissionMapper permissionMapper;
    @Autowired
    private WebPermissionMapper webPermissionMapper;

    @Transactional
    public void saveWebPermission(WebPermissionDto webPermissionDto) {
        Permission permission = BeanMapper.mapper(webPermissionDto, Permission.class);
        WebPermission webPermission = BeanMapper.mapper(webPermissionDto, WebPermission.class);
        permissionMapper.insertSelective(permission);
        webPermissionMapper.insertSelective(webPermission);
    }
}
